<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    use HasFactory;

    const SUCCESS = 1;
    const FAILED  = -1;

    protected $fillable = [
        'order_no', 'app_id', 'user_id', 'sdk_order_no', 'money', 'server_id', 'role_id', 'role_name', 'request'
    ];

    public function success(string $response)
    {
        $this->status = self::SUCCESS;
        $this->response = $response;
        $this->save();
    }

    public function failed(string $response)
    {
        $this->status = self::FAILED;
        $this->response = $response;
        $this->save();
    }
}
